package demo3;

public class Test {
    public static void main(String[] args) {
        //实例内部类的创建需要先实例外部类，再调用外部类new 实例内部类
        OuterClass outerClass = new OuterClass();
        OuterClass.InnerClass innerClass = outerClass.new InnerClass();
        innerClass.method1();
    }
}
class OuterClass{
    public int data1 = 1;
    public static int data2 = 2;
    private int data3 = 3;
    public int data7 = 77;
    public void method(){

    }
    class InnerClass{
        public int data4 = 4;
        //在实例内部类中，若想使用static修饰，只能在后面加上final让其变成常量
        public static final int data5 = 5;
        private int data6 = 6;
        public int data7 = 7;
        public void method1() {
            System.out.println(OuterClass.this.data7);
//            System.out.println(data1);
//            System.out.println(data2);
//            System.out.println(data3);
//            System.out.println(data4);
//            System.out.println(data5);
//            System.out.println(data6);
        }
    }
}
